import { IDataWithError } from '@/service/typing/service-typing'
import type {
  IAcceptCourseUserParam,
  IAddCourseUserParam,
  ICourseInfo,
  ICourseService,
  ICourseUserInfo,
  ICreateCourseParam,
  IGetCourseInfoParam,
  IListCourseUserParam,
  ISetCoursePlaybackParam,
  IUpdateCourseStatusParam
} from '@/service/typing/service/ICourseService'
import { HttpTransfer } from '../transfer/transfer'
import { ICourseURL } from '../transfer/urls/course-url'

export class CourseService implements ICourseService {
  constructor(private readonly http: HttpTransfer, private readonly url: ICourseURL) {}

  createCourse(param: ICreateCourseParam): Promise<IDataWithError<ICourseInfo, any>> {
    return this.http.request(this.url.createCourse, param)
  }
  updateCourse(param: ICreateCourseParam): Promise<IDataWithError<ICourseInfo, any>> {
    return this.http.request(this.url.updateCourse, param)
  }
  setCoursePlayback(param: ISetCoursePlaybackParam): Promise<IDataWithError<any, any>> {
    return this.http.request(this.url.setCoursePlayback, param)
  }
  updateCourseStatus(param: IUpdateCourseStatusParam): Promise<IDataWithError<any, any>> {
    return this.http.request(this.url.updateCourseStatus, param)
  }
  getCourseInfo(param: IGetCourseInfoParam): Promise<IDataWithError<ICourseInfo, any>> {
    return this.http.request(this.url.getCourseInfo, param)
  }
  addCourseUser(param: IAddCourseUserParam): Promise<IDataWithError<ICourseUserInfo, any>> {
    return this.http.request(this.url.addCourseUser, param)
  }
  listCourseUser(param: IListCourseUserParam): Promise<IDataWithError<ICourseUserInfo[], any>> {
    return this.http.request(this.url.listCourseUser, param)
  }
  acceptCourseUser(param: IAcceptCourseUserParam): Promise<IDataWithError<any, any>> {
    return this.http.request(this.url.acceptCourseUser, param)
  }
}
